import 'package:dio/dio.dart';
import 'package:puppy_store/service/requests.dart';
import 'package:puppy_store/models/home_model.dart';

class HomeApi {
  // 获取数据并转化成模型数据返回出去
  static Future<HomeModel> homeFetch() async {
    Response res = await PuppyRequestManager().handleRequest(
      '/home/index',
      'GET',
    );

    // 读取响应体数据中的result字段
    dynamic result = res.data['result'];

    // 将result字段转换成模型数据
    HomeModel homeModel = HomeModel.fromJson(result);

    return homeModel;
  }
}
